package com.wyg.demo.component;

import com.wyg.demo.service.LongDistanceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author ygWen
 * @Description: csv文件定时导入
 * @date 2021/12/31
 */
@Slf4j
@Component
public class CsvImportTask {
    
    @Autowired
    private LongDistanceService longDistanceService;
    
    //每周日八点执行一次
    //@Scheduled(cron = "0 0 8 ? * 1")
    @Scheduled(cron = "0 */2 * * * *")
    private void csvImport() {
        try {
            longDistanceService.csvInsert("E:\\Study\\csvIntoMysql\\long");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
